home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / Graphics / TVPaint / Rexx / LineJagged.rx < prev    next >
Encoding:
Text File  |  1995-11-07  |  1.1 KB  |  118 lines

  1. /*
  2.     param line
  3.  
  4.     Draw a jagged line
  5.     Modify w: the width of the line
  6.     Modify l: the lenght of the step on the line
  7.  
  8. */
  9.  
  10. address 'rexx_TVPaint'
  11.     
  12.     parse ARG m x1 y1 x2 y2 b
  13.     if(m~='Line')then
  14.     do
  15.         tv_warn 'I need LINE parameters'
  16.         exit
  17.     end
  18.  
  19.  
  20.     l=10
  21.     w=5
  22.  
  23.  
  24.     tv_UpdateUndo
  25.     x=x1
  26.     y=y1
  27.  
  28.     iy=1
  29.     dy=y2-y1
  30.     if (dy<0) then
  31.     do
  32.         dy=-dy
  33.         iy=-1
  34.     end
  35.  
  36.  
  37.     ix=1
  38.     dx=x2-x1
  39.     if (dx<0) then
  40.     do
  41.         dx=-dx
  42.         ix=-1
  43.     end
  44.  
  45.     xb=x
  46.     yb=y
  47.     xa=x
  48.     ya=y
  49.     c=1
  50.  
  51.     if (dx>dy) then
  52.     do
  53.         d=dx
  54.         do while (x~==x2)
  55.  
  56.             x=x+ix
  57.             d=d-dy
  58.  
  59.             if (d<0) then
  60.             do
  61.                 y=y+iy
  62.                 d=d+dx
  63.             end
  64.  
  65.             if((x%l)*l == x) then
  66.             do
  67.                 if (c==1) then
  68.                 do
  69.                     tv_line xb yb+w x y-w b
  70.                     c=0
  71.                 end
  72.                 else
  73.                 do
  74.                     tv_line xb yb-w x y+w b
  75.                     c=1
  76.                 end
  77.  
  78.                 xb=x
  79.                 yb=y
  80.             end
  81.         end
  82.     end
  83.     else
  84.     do
  85.         d=dy
  86.         do while (y ~==y2)
  87.  
  88.             y=y+iy
  89.             d=d-dx
  90.  
  91.             if (d<0) then
  92.             do
  93.                 x=x+ix
  94.                 d=d+dy
  95.             end
  96.             if((y%l)*l == y) then
  97.             do
  98.  
  99.                 if (c==1) then
  100.                 do
  101.                     tv_line xb+w yb x-w y b
  102.                     c=0
  103.                 end
  104.                 else
  105.                 do
  106.                     tv_line xb-w yb x+w y b
  107.                     c=1
  108.                 end
  109.  
  110.  
  111.                 xb=x
  112.                 yb=y
  113.             end
  114.         end
  115.     end
  116.  
  117.  
  118.